1. /* sfffcomp.cpp by K.Tsuru */
  2. // function ID = 7001 DRADIX
  3. /****************************************************************
  4. SFraction class
  5. It provides the comparison of two abusolute values and
  6. returns sgn(|m| - |n|) = 1, 0 , -1.
  7. m = m.num/m.den; n = n.num/n.den;
  8. |m| - |n| = ( |m.num|*n.den - m.den*|n.num| ) / (m.den*n.den);
  9. ****************************************************************/
  10. #ifndef SN_H
  11. #include "sn.h"
  12. #endif
  13. int FFCompare(const SFraction& m, const SFraction& n){
  14. //check the diffrence between the number of figures.
  15. //error is one or under, 99*99 (2+2) = 891*11 (3+2)
  16. int df;
  17. df = (int)(m.NumNR().Head()+n.DenNR().Head()) - int(m.DenNR().Head()+n.NumNR().Head());
  18. if(abs(df) > 1) return Sgn(df); //obvious differnce in the number of figures
  19. SLong a, b;
  20. a = m.NumNR()*n.DenNR(); b = m.DenNR()*n.NumNR();
  21. return LLCompare(a, b);
  22. }

sfffcomp.cpp : last modifiled at 2014/05/22 15:52:58(886 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2016/09/13 19:56:38 (Tue Sep 13 19:56:38 2016).